home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byt1186b.arc / DRAGON.DOC < prev    next >
Text File  |  2018-07-12  |  3KB  |  67 lines

  1.  
  2.  
  3. Screen #1
  4. ( begin  Dragon curve )                                         
  5. CREATE CURVE   ( a FORGETable name)                             
  6.                                                                 
  7. CARTESIAN OFF                                                   
  8.                                                                 
  9. : RECURS  SMUDGE ; IMMEDIATE  ( trick verb for recursion)       
  10.                                                                 
  11. VARIABLE ANGLE                                                  
  12. VARIABLE XCOOD                                                  
  13. VARIABLE YCOOD                                                  
  14. VARIABLE STEPSIZE                                               
  15.                                                                 
  16. : TURN (  deltangle-- | turn sign*delta)                        
  17.   ANGLE +! ;                                                    
  18.                                                                 
  19. 2 4 THRU 
  20.  
  21.  
  22.  
  23. Screen #2
  24. : MOVE ( -- | takes a step in present turtle direction)         
  25.   STEPSIZE @  DUP                                               
  26.   ANGLE @  COS *  10000 /  ( r* cos  of theta)  XCOOD @  +      
  27.   DUP ( newX)  XCOOD ! ( update X)                              
  28.   SWAP                                                          
  29.   ANGLE @  SIN *  10000 /   ( r* sine theta )   YCOOD @  +      
  30.   DUP ( newY)  YCOOD ! ( update Y)                              
  31.   DRAW.TO   ;                                                   
  32.   
  33.  
  34.  
  35. Screen #3
  36. : DRAGON ( sign level-- |  )                                    
  37.   DUP ( level) 0=                                               
  38.   IF  ( at bottom of recursion)                                 
  39.     DROP ( level)  DROP ( sign)   MOVE ( by stepsize)           
  40.   ELSE                                                          
  41.     OVER  45 * TURN  ( getsign and turn)                        
  42.     1 ( newsign)                                                
  43.     OVER   1-       ( level=level-1)                            
  44.     RECURS DRAGON  RECURS                                       
  45.                                                                 
  46.     OVER  -90 * TURN ( getsign & turn)                          
  47.     -1 ( newsign)  ( edit to +1 for diff curve)                 
  48.     OVER  1-           ( level=level-1)                         
  49.     RECURS DRAGON RECURS                                        
  50.     DROP ( input level)  45 * TURN  ( getsign and turn)         
  51.   THEN  ;                                                       
  52.  
  53.  
  54.  
  55. Screen #4
  56. : DCURVE ( level  --|  )                                        
  57.   ( init pen position)                                          
  58.   PAGE   100 XCOOD !    90 YCOOD !   360 6 *  ANGLE !           
  59.   WHITE PENPAT  XCOOD @  YCOOD @  MOVE.TO                       
  60.                                                                 
  61.   PEN.NORMAL                                                    
  62.   1 STEPSIZE !                                                  
  63.   1 SWAP ( level) DRAGON                                        
  64.                                                                 
  65.   WHITE PENPAT   4 10 MOVE.TO    PEN.NORMAL ;                   
  66.  
  67.